<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>FormLayout 表单布局</title>
		<meta http-equiv="content-type" content="text/html; charset=UTF-8" />

		<script src="__PUBLIC__/scripts/boot.js" type="text/javascript"></script>

		<style type="text/css">
			.td1 {
				text-align: right;
			}

		</style>

	</head>
	<body>
		<h1>项目融资信息</h1>
		<div style="width:900px;">
			<div class="mini-toolbar" style="padding:2px;">
				<table style="width:100%;">
					<tr>
						<td style="width:100%;"><span>项目名称: {$_SESSION['pname']}</span> &nbsp <span>项目经理: {$_SESSION['managername']}</span></td>
						<td style="white-space:nowrap;"></td>
					</tr>
					<tr>
		<td style="width: 100%;"><a class="mini-button"
			iconCls="icon-add" onclick="showWindow()">修改</a></td>
		<td style="white-space: nowrap;"></td>
	</tr>
				</table>
			</div>
		</div>
		<br />
		
		
		<div id="form0" style="width: 904px;">
		<fieldset>

				<table>
					<tr>
						<td class="td1"><label >本轮计划融资规模</label></td>
						<td id="scale">
						 {$list["scale"]}
						（万元） </td>
					</tr>
					<tr>
						<td class="td1"><label for="type" >当年预期年度</label></td>
						<td id="type">
						 {$list["type"]}
						 &nbsp;
						 {$list["thisyear"]}
						（万元） </td>
					</tr>
					<tr>
						<td class="td1"><label  >项目总市值（POST） </label></td>
						<td id="post">
						 {$list["post"]}
						</td>
					</tr>
					<tr>
						<td class="td1"><label >本轮估值</label></td>
						<td id="assessment">
						<switch name="list['type']" >
						<case value="净利润">PE</case>
						<case value="EBITA">EBITA</case>
						<case value="销售额">PS Multiple</case>
						<case value="其他">其他</case>
						</switch>
						&nbsp;
						 {$list["assessment"]}
						（万元） </td>
					</tr>
					<tr>
						<td class="td1"><label>本轮领投与否 </label></td>
						<td id="isleader">
						<switch name="list['isleader']" >
						<case value="true">是</case>
						<case value="false">否</case>
						</switch>
	
						</td>
					</tr>
					<tr>
						<td class="td1"><label >其他可能机构投资人 </label></td>
						<td id="other">
							 {$list["other"]}
						
						</td>
					</tr>
				</table>

			</fieldset>
		</div>
		
		 <div id="win1" class="mini-window" title="详细内容" style="width: 800px;"
	showMaxButton="true" showToolbar="true" showFooter="true"
	showModal="true" allowResize="true" allowDrag="true"> 
		<div id="form1">
			<fieldset>

				<table>
					<tr>
						<td class="td1"><label >本轮计划融资规模</label></td>
						<td >
						<input class="mini-textbox" id="scale" type="text" name="scale"   />
						（万元） </td>
					</tr>
					<tr>
						<td class="td1"><label for="type" >当年预期年度</label></td>
						<td >
						<input class="mini-combobox" id="type" name="type" onvaluechanged="typechange()" url="__PUBLIC__/data/incometype.txt"   value=""  textField="text" valueField="id" />
						&nbsp;
						<input class="mini-textbox" id="thisyear" type="text" name="thisyear"   />
						（万元） </td>
					</tr>
					<tr>
						<td class="td1"><label  >项目总市值（POST） </label></td>
						<td >
						<input class="mini-textbox" id="post" type="text" name="post"   />
						</td>
					</tr>
					<tr>
						<td class="td1"><label >本轮估值</label></td>
						<td >
						<input id="type2" class="mini-combobox"  url="__PUBLIC__/data/assessmenttype.txt"   value=""  textField="text" valueField="id" />
						&nbsp;
						<input class="mini-textbox" id="assessment" type="text" name="assessment"   />
						（万元） </td>
					</tr>
					<tr>
						<td class="td1"><label>本轮领投与否 </label></td>
						<td ><div  name="isleader" class="mini-checkbox" checked="true"  text="是"></div></td>
					</tr>
					<tr>
						<td class="td1"><label >其他可能机构投资人 </label></td>
						<td >
						<input  class="mini-textbox" id="other" type="text" name="other" />
						</td>
					</tr>
				</table>

			</fieldset>

			<br />

			
			<a class="mini-button" iconCls="icon-save" plain="true" onclick="updateForm()">更新</a> 
			<a class="mini-button" iconCls="icon-redo" plain="true" onclick="loadForm()()">还原</a> 


		</div>
		</div>
		<script type="text/javascript">
			mini.parse();
			var olddata;
			loadForm();

			function updateForm() {
				//提交表单数据
				if(checkauth()) {
					var form = new mini.Form("#form1");
					var data = form.getData();
					//获取表单多个控件的数据
					//var json = mini.encode(data);   //序列化成JSON
					$.ajax({
						url : "__APP__/Post/pre_1_update",
						type : "post",
						data : {
							Data : data
						},
						success : function(text) {
							alert("提交成功!");
							olddata = form.getData();
							$("#scale").html(data.scale+"（万元）");		
							$("#type").html(data.type+"&nbsp;"+data.thisyear);	
							$("#other").html(data.other);	
							$("#post").html(data.post+"（万元）");	
							var type2;
							if(data.type=="净利润")
								type2="PE&nbsp;";
							else if(data.type=="EBITA")
								type2="EBITA&nbsp;";
							else if(data.type=="销售额")
								type2="PS Multiple&nbsp;";
							else if(data.type=="其他")
								type2="其他&nbsp;";
							$("#assessment").html(type2+data.assessment+"（万元）");
							if(data.isleader=="true")
							$("#isleader").html("是");	
							else
							$("#isleader").html("否");		
						}
					});
				}
			}

			function loadForm() {
				//加载表单数据
				var form = new mini.Form("#form1");
				//var pid = document.getElementById("pid").value;
				//mini.alert(pid);
				$.ajax({
					url : "__APP__/Post/pre_1",
					type : "post",
					success : function(text) {
						var data = mini.decode(text);

						//反序列化成对象
						if(data['error'])
							mini.alert("尚未选择项目！", "提示", function() {
								window.CloseOwnerWindow('refresh');
							});
						form.setData(data);
						typechange();
						//设置多个控件数据
						
					}
				});
				olddata = form.getData();
			}

			function getForm() {
				//提交表单数据
				var form = new mini.Form("#form1");
				form.validate();
				if(form.isValid() == false)
					return;

				var data = form.getData();
				//获取表单多个控件的数据
				var json = mini.encode(data);
				//序列化成JSON
				mini.alert(json);
			}

			function resetForm() {
				var form = new mini.Form("#form1");
				form.reset();
			}

			function typechange() {
				var t1 = mini.get("type");
				var t2 = mini.get("type2");

				t2.setValue(t1.getValue());
			}

			function getData() {
				var form = new mini.Form("#form1");
				var data = form.getData();
				var json1 = mini.encode(data);
				//alert(json1);
				var json2 = mini.encode(olddata);
				// alert(json2);
				if(json2 == "null" && json1 == '{"type":"","condition":"","content":"","detailcontent":""}')
					return "无变化";
				if(json1 != json2)
					return "已经改变内容，尚未提交，";
				else
					return "无变化";

			}

			function CloseWindow(action) {

				if(window.CloseOwnerWindow)
					window.CloseOwnerWindow(action);
				
				else
					window.close();

			}

			function checkauth() {
				var state = "{$_SESSION['state']}";
				if(state=="休眠"){
					mini.alert("项目休眠，需要在基本信息表中激活！");
					return false;
				}
				var uname = "{$_SESSION['nickname']}";
				var mname = "{$_SESSION['membername']}";
				var depart = "{$_SESSION['depart']}";
				var pos = mname.indexOf(uname);
				if(pos == -1 && depart != "营运" && uname != "{$_SESSION['managername']}") {
					mini.alert("无操作权限！");
					return false;
				} else
					return true;
			}
			function showWindow() {
		var win = mini.get("win1");
		win.show();
	}
		</script>

	</body>
</html>